import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ModelPageList,
  ModelgetEpisodeVideoUrl,
  ModelMovieId,
  ModelSaveMovie,
} from "./types";

// 剧集列表
export function movieList(
  data: ModelPageList
): AxiosPromise<Record<string, any>> {
  return request({
    url: "/api/Operas/distributor/search",
    method: "get",
    params: data,
  });
}

// 删除剧集
export function deleteMovie(
  data: ModelMovieId
): AxiosPromise<Record<string, any>> {
  return request({
    url: "/api/m1/3246697-0-default/api/movie/delete",
    method: "post",
    data,
  });
}

// 播放列表
export function listByMovieId(data: number): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/${data}`,
    method: "get",
  });
}

// 获取播放视频
export function getEpisodeVideoUrl(
  data: ModelgetEpisodeVideoUrl
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/video-url/${data.operaId}`,
    method: "get",
    params: { episode: data.episode },
  });
}

// 保存剧集收费设置
export function setProductSave(
  data: ModelSaveMovie
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/charge-setting/${data.id}`,
    method: "patch",
    data,
  });
}

//  推广链接-  星图推广平台生成复制链接参数
export function metadata(data: Number): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/${data}/dy/metadata`,
    method: "get",
  });
}
